package com.gcosc.hly.codejava.controller;

import com.gcosc.hly.codejava.entity.Answer;
import com.gcosc.hly.codejava.params.QueryParams;
import com.gcosc.hly.codejava.result.Result;
import com.gcosc.hly.codejava.service.AnswerService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/answer")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AnswerController {

    private final AnswerService answerService;

    @GetMapping("/list")
    public Result list(QueryParams params){
        return Result.ok(answerService.queryParams(params));
    }

    /**
     * 详情
     * */
    @GetMapping("/detail/{id}")
    public Result detail(@PathVariable int id){
        return Result.ok(answerService.getDetail(id));
    }


    @PostMapping("/edit")
    public Result edit(@RequestBody Answer answer){
        return Result.ok(answerService.edit(answer));
    }

}
